package com.kinyx.framework.enums.impl;

import com.kinyx.framework.enums.IErrorCodeEnum;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 错误编码枚举（定义错误用于开发者快速定位错误来源，不可以直接在应用层输出错误信息，因而不支持国际化。）
 */
@Getter
@RequiredArgsConstructor
public enum ErrorCode1 implements IErrorCodeEnum {

	CODE_ERROR_12(12, "Annotation on[${className}#${fieldName}], @javax.persistence.Id conflict with @javax.persistence.Column(insertable=false)"), //
	CODE_ERROR_13(13, "Annotation on[${className}#${fieldName}], @javax.persistence.Id conflict with @javax.persistence.Column(updatable=true)"), //

	CODE_ERROR_41(41, "Annotation on[${className}], @javax.persistence.Entity(name=\"${str1}\") conflict with @javax.persistence.Table(name=\"${str2}\")"), //
	CODE_ERROR_42(42, "Annotation on[${className}], @javax.persistence.Entity(name=\"${str1}\") conflict with @org.hibernate.annotations.Table(name=\"${str3}\")"), //
	CODE_ERROR_43(43, "Annotation on[${className}], @javax.persistence.Table(name=\"${str2}\") conflict with @org.hibernate.annotations.Table(name=\"${str3}\")"), //

	CODE_ERROR_101(101, "DriverManager.getConnection(\"${jdbcUrl}\", \"${username}\", \"${password}\")"), //
	CODE_ERROR_102(102, "Connection.prepareStatement(\"${sql}\")"), //
	CODE_ERROR_103(103, "PreparedStatement.setObject(${parameterIndex}, ${param})"), //
	CODE_ERROR_104(104, "ResultSet.getMetaData()"), //
	CODE_ERROR_105(105, "ResultSetMetaData.getColumnCount()"), //
	CODE_ERROR_106(106, "ResultSetMetaData.getColumnName(${column})"), //
	CODE_ERROR_107(107, "PreparedStatement.executeQuery()"), //
	CODE_ERROR_108(108, "PreparedStatement.executeUpdate()"), //
	CODE_ERROR_109(109, "Connection.setAutoCommit(false)"), //
	CODE_ERROR_110(110, "Connection.commit()"), //
	CODE_ERROR_111(111, "ResultSet.getObject(${columnIndex})"), //
	CODE_ERROR_112(112, "ResultSet.next()"), //
	CODE_ERROR_113(113, "PreparedStatement.setMaxRows(${maxCount})"), //

	CODE_ERROR_501(501, "can not load config [${key}] from config file:[${fileName}]"), //

	CODE_ERROR_801(801, "result more than one column"), //
	CODE_ERROR_802(802, "result more than one row"), //
	CODE_ERROR_803(803, "SQL only"), //
	CODE_ERROR_804(804, "SQL[${SQL}] statement type[${type}] error"), //

	;

	/** 错误编码 */
	private final int errorCode;
	/** 错误信息 */
	private final String errorMessage;

	@Override
	public int section() { return 0; }

}
